package com.tancire.web.controller.net;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.net.domain.AuthInfo;
import com.tancire.net.service.IAuthInfoService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 认证应用（资源）信息Controller
 *
 * @author chenchao
 * @date 2023-11-18
 */
@RestController
@RequestMapping("/net/authInfo")
public class AuthInfoController extends BaseController {
    @Resource
    private IAuthInfoService authInfoService;

    /**
     * 查询认证应用（资源）信息列表
     */
    @PreAuthorize("@ss.hasPermi('net:authInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(AuthInfo authInfo) {
        startPage();
        List<AuthInfo> list = authInfoService.selectAuthInfoList(authInfo);
        return getDataTable(list);
    }

    /**
     * 查询 平台 认证应用信息列表
     */
    @PreAuthorize("@ss.hasPermi('net:authInfo:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll(AuthInfo authInfo) {
        List<AuthInfo> list = authInfoService.selectAuthInfoListAll(authInfo);
        return AjaxResult.success(list);
    }

    /**
     * 导出认证应用（资源）信息列表
     */
    @PreAuthorize("@ss.hasPermi('net:authInfo:export')")
    @Log(title = "认证应用（资源）信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuthInfo authInfo) {
        List<AuthInfo> list = authInfoService.selectAuthInfoList(authInfo);
        ExcelUtil<AuthInfo> util = new ExcelUtil<AuthInfo>(AuthInfo.class);
        util.exportExcel(response, list, "认证应用（资源）信息数据");
    }

    /**
     * 获取认证应用（资源）信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('net:authInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(authInfoService.selectAuthInfoById(id));
    }

    /**
     * 新增认证应用（资源）信息
     */
    @PreAuthorize("@ss.hasPermi('net:authInfo:add')")
    @Log(title = "认证应用（资源）信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuthInfo authInfo) {
        return toAjax(authInfoService.insertAuthInfo(authInfo));
    }

    /**
     * 修改认证应用（资源）信息
     */
    @PreAuthorize("@ss.hasPermi('net:authInfo:edit')")
    @Log(title = "认证应用（资源）信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuthInfo authInfo) {
        return toAjax(authInfoService.updateAuthInfo(authInfo));
    }

    /**
     * 删除认证应用（资源）信息
     */
    @PreAuthorize("@ss.hasPermi('net:authInfo:remove')")
    @Log(title = "认证应用（资源）信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(authInfoService.deleteAuthInfoByIds(ids));
    }
}
